/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.history;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "history_clearing_currencyrates")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HistoryClearingCurrencyRates.findAll", query = "SELECT h FROM HistoryClearingCurrencyRates h"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findById", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.id = :id"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findByClearingDate", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.clearingDate = :clearingDate"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findByAskCurrency", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.askCurrency = :askCurrency"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findByBidCurrency", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.bidCurrency = :bidCurrency"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findByRatePrice", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.ratePrice = :ratePrice"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findByOwnUserID", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.ownUserID = :ownUserID"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findByAlterUserID", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.alterUserID = :alterUserID"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findByCreateTime", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.createTime = :createTime"),
    @NamedQuery(name = "HistoryClearingCurrencyRates.findByTimeStamp", query = "SELECT h FROM HistoryClearingCurrencyRates h WHERE h.timeStamp = :timeStamp")})
public class HistoryClearingCurrencyRates implements Serializable {
	public static byte[] EnCode(HistoryClearingCurrencyRates msg) throws IOException {
		Codec<HistoryClearingCurrencyRates> Lcode = ProtobufProxy.create(HistoryClearingCurrencyRates.class);
		return Lcode.encode(msg);
	}
	public static HistoryClearingCurrencyRates DeCode(byte[] data) throws IOException {
	Codec<HistoryClearingCurrencyRates> Lcode = ProtobufProxy.create(HistoryClearingCurrencyRates.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    @Protobuf
	private Integer id;
    @Basic(optional = false)
    @Column(name = "ClearingDate")
    @Temporal(TemporalType.DATE)
    private Date clearingDate;
	@Protobuf
	private long clearingDateL;
    @Basic(optional = false)
    @Column(name = "AskCurrency")
    @Protobuf
	private String askCurrency;
    @Basic(optional = false)
    @Column(name = "BidCurrency")
    @Protobuf
	private String bidCurrency;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "RatePrice")
    @Protobuf
	private Float ratePrice;
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public HistoryClearingCurrencyRates() {
    }

    public HistoryClearingCurrencyRates(Integer id) {
        this.id = id;
    }

    public HistoryClearingCurrencyRates(Integer id, Date clearingDate, String askCurrency, String bidCurrency) {
        this.id = id;
        this.clearingDate = clearingDate;
		this.clearingDateL = CodeTool.DateToLong(clearingDate);
        this.askCurrency = askCurrency;
        this.bidCurrency = bidCurrency;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getClearingDate() {
        return clearingDate;
    }

    public void setClearingDate(Date clearingDate) {
        this.clearingDate = clearingDate;
        this.setClearingDateL(CodeTool.DateToLong(clearingDate));
    }

    public String getAskCurrency() {
        return askCurrency;
    }

    public void setAskCurrency(String askCurrency) {
        this.askCurrency = askCurrency;
    }

    public String getBidCurrency() {
        return bidCurrency;
    }

    public void setBidCurrency(String bidCurrency) {
        this.bidCurrency = bidCurrency;
    }

    public Float getRatePrice() {
        return ratePrice;
    }

    public void setRatePrice(Float ratePrice) {
        this.ratePrice = ratePrice;
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HistoryClearingCurrencyRates)) {
            return false;
        }
        HistoryClearingCurrencyRates other = (HistoryClearingCurrencyRates) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.history.HistoryClearingCurrencyRates[ id=" + id + " ]";
    }

    public long getClearingDateL() {
        return clearingDateL;
    }

    public void setClearingDateL(long clearingDateL) {
        this.clearingDateL = clearingDateL;
		this.clearingDate = CodeTool.LongToDate(clearingDateL);
    }
    
}
